<template>
  <div>
    <el-card class="card">
      <el-input v-model="query_registID" class="my_el_input" placeholder="请输入挂号ID">
        <el-button slot="append" icon="el-icon-search" @click="doQuery"></el-button>
      </el-input>
      <el-table
          :data="list"
          border
          height="600"
          stripe
          style="width: 100%">
        <el-table-column
            fixed
            label="ID"
            prop="id"
            width="60">
        </el-table-column>
        <el-table-column
            label="病例ID"
            prop="medicalID"
            width="80">
        </el-table-column>
        <el-table-column
            label="挂号ID"
            prop="registID"
            width="100">
        </el-table-column>
        <el-table-column
            label="目的要求"
            prop="objective"
            width="80">
        </el-table-column>
        <el-table-column
            label="开立时间"
            prop="CreationTime"
            width="155">
        </el-table-column>
        <el-table-column
            label="项目名称"
            prop="name"
            width="120">
        </el-table-column>
        <el-table-column
            label="检查人员ID"
            prop="checkOperID"
            width="120">
        </el-table-column>
        <el-table-column
            label="开立医生ID"
            prop="doctorID"
            width="120">
        </el-table-column>
        <el-table-column
            label="检查部位"
            prop="position"
            width="120">
        </el-table-column>
        <el-table-column
            label="状态"
            prop="state"
            width="120">
        </el-table-column>
        <el-table-column label="操作" width="100px">
          <template slot-scope="scope">
            <el-button plain type="warning" @click="doGet(scope.row)">录入</el-button>
          </template>
        </el-table-column>

      </el-table>
    </el-card>
    <el-dialog
        :visible.sync="dialogUpdate"
        center
        title="发票信息"
        width="45%">
      <el-form
          ref="invoiceInFormation"
          :model="checkApplyInFormation"
          :rules="invoiceRules"
          label-width="150px">
        <el-form-item label="ID:" prop="invoiceNum">
          <el-input v-model="checkApplyInFormation.id" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="病例ID:" prop="money">
          <el-input v-model="checkApplyInFormation.medicalID" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="挂号ID:" prop="state">
          <el-input v-model="checkApplyInFormation.registID" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="目的要求:">
          <el-input v-model="checkApplyInFormation.objective" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="检查部位:">
          <el-input v-model="checkApplyInFormation.position" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="开立医生ID:">
          <el-input v-model="checkApplyInFormation.doctorID" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="开立时间:">
          <el-input v-model="checkApplyInFormation.CreationTime" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="检查人员ID:" prop="back">
          <el-input v-model="checkApplyInFormation.checkOperID" :disabled="true" class="box-card"></el-input>
        </el-form-item>
        <el-form-item label="结果:" prop="result">
          <el-input v-model="checkApplyInFormation.result" class="box-card" placeholder="结果"></el-input>
        </el-form-item>
      </el-form>
      <!--      <template slot-scope="scope">-->
      <span slot="footer" class="dialog-footer">
            <el-button @click="dialogUpdate = false">取 消</el-button>
            <el-button type="primary" @click="doUpdate()">修改</el-button>
        </span>
      <!--      </template>-->
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      invoice: [],
      query_registID: '',
      checkApplyInFormation: {
        id: '',
        medicalID: '',
        registID: '',
        objective: '',
        state: '',
        CreationTime: '',
        name: '',
        checkOperID: '',
        doctorID: '',
        position: '',
        Result: '',
      },
      dialogUpdate: false,
      temp: '',
      invoiceRules: {
        result: [{required: true, message: '请输入检查结果', trigger: 'blur'}],
      }
    }
  },
  created() {
    this.doQuery();
  },
  mounted() {
    this.initData();
  },
  methods: {
    initData() {
      this.$axios.post('/input/selectAllCheckApply').then((resp) => {
        this.list = resp.data.data;
        console.log('list=', this.list)
      }).catch((err) => {
        console.log("err", err);
      })
    },
    doQuery() {
      this.$axios.post(`/input/selectAllCheckApply?RegistID=${this.query_registID}`).then((resp) => {
        this.list = resp.data.data;
        console.log('list=', this.list)
      }).catch((err) => {
        console.log("err", err);
      })
      this.initData();
    },
    doUpdate() {
      console.log(this.checkApplyInFormation);
      // this.$refs['checkApplyInFormation'].validate(valid => {
      //   if(valid){
      this.$axios.post('/input/updateCheckApply', this.checkApplyInFormation).then((resp) => {
        console.log('checkApplyInFormation=', this.checkApplyInFormation)
      }).catch((err) => {
        console.log("err", err);
      })
      this.dialogUpdate = false;
      //   }
      // })
    },
    doGet(data) {
      this.dialogUpdate = true;
      console.log(data);
      this.invoice = data;
      this.checkApplyInFormation = data;
    },
  }
}
</script>

<style scoped="scoped">
.card {
  background: #ececec;
  border: 1px solid;
}

.box-card {
  width: 480px;
  height: 50px;
}

.input-with-select {
  background-color: #fff;
}

.my_el_input {
  width: 400px;
}
</style>
